package org.rayson.server.rpc;

import org.rayson.api.Invocation;
import org.rayson.api.Protocol;
import org.rayson.api.exception.ProtocolException;
import org.rayson.api.server.ServerRequest;
import org.rayson.api.server.Session;
import org.rayson.server.http.HttpServerRequest;
import org.rayson.server.transport.ServerConnection;
import org.rayson.share.rpc.InvocationImpl;

public class ServerRequestImpl implements ServerRequest {
	private final HttpServerRequest httpMsg;
	private final ServerConnection connection;
	private Invocation invocation;

	public ServerRequestImpl(final HttpServerRequest httpMsg,
			final ServerConnection connection) {
		super();
		this.httpMsg = httpMsg;
		this.connection = connection;
	}

	/**
	 * @return the connection
	 */
	public ServerConnection getConnection() {
		return connection;
	}

	@Override
	public Invocation getInvocation() {
		return invocation;
	}

	@Override
	public int getLocalPort() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getRemoteAddr() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getRemotePort() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Protocol getService() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Session getSession() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Session getSession(final boolean create) {
		// TODO Auto-generated method stub
		return null;
	}

	public Invocation parseInvocation() throws ProtocolException {
		this.invocation = InvocationImpl.parse(httpMsg);
		return this.invocation;
	}
}